// Copyright 2023 Huawei Cloud Computing Technology Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef HUAWEICLOUD_CLOUDPHONEACCESS_ENGINE_CAELOCALDATAHANDLETHREAD_H
#define HUAWEICLOUD_CLOUDPHONEACCESS_ENGINE_CAELOCALDATAHANDLETHREAD_H

#include <mutex>
#include "../cae_common/CaeThread.h"
#include "../cae_common/CaeVirtualDeviceConfig.h"
#include "../cae_CPHMediaEngine/CPHMediaEngine.h"

class CaeLocalDataHandleThread : public CaeThread{
public:
    CaeLocalDataHandleThread(uint16_t version, uint16_t devType, uint16_t devId, uint16_t width, uint16_t height, uint32_t format);
    CaeLocalDataHandleThread(uint16_t version, uint16_t devType, uint16_t devId, uint16_t sampleRate, uint32_t format);
    ~CaeLocalDataHandleThread() override;

    void Run() override;

private:
    uint32_t m_format = VMI_I420;
    uint16_t m_width = 1280;
    uint16_t m_height = 720;
    uint16_t m_sampleRate = 48000;
    uint16_t m_version = 0;
    uint16_t m_devType = 0;
    uint16_t m_devId = 0;

    void CaeLocalDataSendTaskEntry();

    void InjectH264(MSG_HEADER header);
    void InjectYuv(MSG_HEADER header);
    void InjectJpeg(MSG_HEADER header);
    void InjectPcm(MSG_HEADER header);

};


#endif //HUAWEICLOUD_CLOUDPHONEACCESS_ENGINE_CAELOCALDATAHANDLETHREAD_H
